package com.lx.api.weight;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lx.core.weight.entity.dto.SettlementDTO;
import com.lx.core.weight.entity.dto.WeightUpdateDTO;
import com.lx.core.weight.entity.vo.SettlementVO;
import com.lx.core.weight.entity.vo.WeightUpdateVO;
import com.lx.core.weight.service.SettlementService;
import com.lx.core.weight.service.WeightUpdateService;
import com.lx.framework.common.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 结算服务
 *
 * @author lx
 * @date 2025/08/26 09:09
 **/
@RestController
@Api(tags = "结算管理")
@RequestMapping("/weight/settlement")
public class SettlementController {

    private final SettlementService settlementService;
    private final WeightUpdateService weightUpdateService;

    public SettlementController(SettlementService settlementService,WeightUpdateService weightUpdateService) {
        this.settlementService = settlementService;
        this.weightUpdateService = weightUpdateService;
    }

    @ApiOperation(value = "获取结算列表分页")
    @ApiResponses(@ApiResponse(code = 200, message = "操作成功", response = SettlementVO.class))
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public R page(@RequestBody SettlementDTO settlementDTO){
        IPage<SettlementVO> page = new Page<>(settlementDTO.getCurrent(), settlementDTO.getSize());
        SettlementVO settlementVO = this.settlementService.page(page, settlementDTO);
        return R.success("操作成功", settlementVO);
    }
    @ApiOperation(value = "获取单价更新列表分页")
    @ApiResponses(@ApiResponse(code = 200, message = "操作成功", response = SettlementVO.class))
    @RequestMapping(value = "/weightUpdatePage", method = RequestMethod.POST)
    public R weightUpdatePage(@RequestBody WeightUpdateDTO weightUpdateDTO){
        IPage<WeightUpdateVO> page = new Page<>(weightUpdateDTO.getCurrent(), weightUpdateDTO.getSize());
        WeightUpdateVO settlementVO = this.weightUpdateService.page(page, weightUpdateDTO);
        return R.success("操作成功", settlementVO);
    }
}
